import java.applet.*;
import java.awt.event.*;
import java.awt.*;
import netscape.javascript.*;

/*
JSObject win = (JSObject)JSObject.getWindow(this);
JSObject inputText = (JSObject) win.eval("document.forms[0].elements[0]");
String value = (String)inputText.getMember("value");  // read form value
inputText.setMember("value" , value + " new stuff");  // write form value
PrivilegeManager.enablePrivilege("UniversalBrowserRead");
PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
*/

 public class JSjava extends Applet
 implements ActionListener {
 Button b1,b2;
 TextField tf;

 JSObject win;

 public void init(){
  setLayout(new FlowLayout());
  tf = new TextField(10);
  b1 = new Button("to FORM");
  b2 = new Button("from FORM");

  b1.addActionListener(this);
  b2.addActionListener(this);
  add(tf);add(b1);add(b2);
  }

 public void actionPerformed(ActionEvent ae) {
  if (ae.getSource() == b1) {
     // send TO FORM
     JSObject win = (JSObject)JSObject.getWindow(this);
     win.eval("setHTMLInputText('"+tf.getText()+"');");
     }
  if (ae.getSource() == b2) {
     // receive FROM FORM
     JSObject win = (JSObject)JSObject.getWindow(this);
     tf.setText((String)win.eval("getHTMLInputText();"));
     }
  }
}